#include "check.h"
#include "common_interface.h"
#include "check_interface.h"
#include "common_errno.h"

static char left[] = "123456";
static char right[] = "123456789123456789";

static char correct_plus[] = "123456789123580245";
// static char correct_mult[] = "15241481358025481342784";

START_TEST(test_plus_ok) {
    char operation_result[32] = { 0 };
    int length = 0;
    int ret = 0;

    memset(operation_result, 0, sizeof(operation_result));
    ret = common_big_number_plus(operation_result, &length, sizeof(operation_result), left, right);
    
    ck_assert_int_eq(ret, COM_OK);
    ck_assert_int_eq(length, strlen(correct_plus));
    ck_assert_int_eq(strlen(correct_plus), strlen(operation_result));
    ck_assert_mem_eq(correct_plus, operation_result, length);
}
END_TEST

START_TEST(test_plus_input) {
    char operation_result[32] = { 0 };
    int length = 0;

    memset(operation_result, 0, sizeof(operation_result));
    ck_assert_int_eq(common_big_number_plus(NULL, &length, sizeof(operation_result), left, right), COM_BAD_INPUT);
    ck_assert_int_eq(common_big_number_plus(operation_result, NULL, sizeof(operation_result), left, right), COM_BAD_INPUT);
    ck_assert_int_eq(common_big_number_plus(operation_result, &length, 0, left, right), COM_BIG_NUMBER_OUT_BUF_SMALL);
    ck_assert_int_eq(common_big_number_plus(operation_result, &length, sizeof(operation_result), NULL, right), COM_BAD_INPUT);
    ck_assert_int_eq(common_big_number_plus(operation_result, &length, sizeof(operation_result), left, NULL), COM_BAD_INPUT);
    ck_assert_int_eq(common_big_number_plus(operation_result, &length, 1, left, right), COM_BIG_NUMBER_OUT_BUF_SMALL);
}
END_TEST

Suite *check_big_number(void)
{
    Suite *s;
    TCase *tc_core;

    s = suite_create("base64 test");

    tc_core = tcase_create("core");
    tcase_add_test(tc_core, test_plus_ok);
    tcase_add_test(tc_core, test_plus_input);

    suite_add_tcase(s, tc_core);

    return s;
}